package com.zhoug.common.framework.eventbus;


import org.greenrobot.eventbus.EventBus;

import androidx.annotation.NonNull;

/**
 * @Author HK-LJJ
 * @Date 2020/3/10
 * @Description
 */
public class EventBusUtils {

    /**
     * 获取EvenBus
     * @return
     */
    public static EventBus getEventBus() {
        return EventBus.getDefault();
    }

    /**
     * 注册事件监听
     *
     * @param subscriber
     */
    public static void register(Object subscriber) {
        getEventBus().register(subscriber);
    }

    /**
     * 取消事件注册
     *
     * @param subscriber
     */
    public static void unregister(Object subscriber) {
        getEventBus().unregister(subscriber);
    }

    /**
     * 发送事件
     * @param event
     */
    public static void post(@NonNull EventMessage event) {
        getEventBus().post(event);
    }



    /**
     * 发送粘性事件:可以被以后才注册监听该事件的接受者接收到
     * @param event
     */
    public static void postSticky(@NonNull EventMessage event) {
        getEventBus().postSticky(event);
    }


    //>>>>>>>>>>>>>>>定义常用的事件post方法>>>>>>>>>>>>>>>>>>>>>


}
